﻿using AutoMapper;
using Castle.Core.Internal;
using HBKY.Shop.Common.Configurations;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace HBKY.Shop.Extensions.ServiceExtensions
{
    /// <summary>
    /// Automapper 启动服务
    /// </summary>
    public static class AutoMapperSetup
    {
        public static void AddAutoMapperSetup(this IServiceCollection services)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));

            var types = AppDomain.CurrentDomain
                      .Load(AssemblyConfig._serviceAssemblyName)
                      .GetTypes().FindAll(o => o.BaseType.Name == typeof(Profile).Name);
            services.AddAutoMapper(types);
        }
    }
}
